<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>门户路由核心管理系统</title>
<jsp:include page="/resources/global/jsp/init.jsp" />
<script type="text/javascript"
	src='${pageContext.request.contextPath }/resources/global/js/index-1.4.3.js'></script>
<script type="text/javascript">
	var userId = "${sessionScope.loginUser.id}";
	var iframe = $("<iframe width=\"100%\" height=\"100%\" name='iframe' id=\"iframe\" frameborder=\"0\"/>");
	var window = $("#user_edit");
	function modifyPasswd(userId) {
		openDialog(userId);
	}
	function openDialog(userId) {
		//用户弹框
		var jsp = "";
		var title = "";
		title = "用户修改密码";
		$("#tr_passwordAgain").css({
			display : "none"
		});
		jsp = "auth/MngUserController/edit.do?action=" + "update" + "&" + "id=" + userId;
		iframe.attr({
			src : jsp,
			width : '100%',
			height : '100%',
			frameborder : '0'
		});
		// iframe加载完成
		if (iframe[0].attachEvent) {
			iframe[0].attachEvent("onload", function() {
				iframe.contents().find("#tr_passwordAgain").css({
					display : "none"
				});
				iframe.contents().find("#txt_password").val("******");
				iframe.contents().find("#txt_name").prop({readonly:true});
				iframe.contents().find("#btn_edit_password").on("click", function() {
					if ($(this).html() == "修改") {
						$(this).html("取消");
						iframe.contents().find("#txt_password").val("");
						iframe.contents().find("#txt_password").val("").prop({"readonly" : false});
						iframe.contents().find("#txt_passwordAgain").val("");
						// 火狐
						iframe.contents().find("#tr_passwordAgain").css({
							display : "table-row"
						});
					} else {
						$(this).html("修改");
						iframe.contents().find("#txt_password").val("******");
						iframe.contents().find("#txt_password").val("").prop({
							"readonly" : true
						});
						iframe.contents().find("#txt_passwordAgain").val("");
						iframe.contents().find("#tr_passwordAgain").css({
							display : "none"
						});
					}
				});
			});
		} else {
			iframe[0].onload = function() {
				iframe.contents().find("#tr_passwordAgain").css({
					display : "none"
				});
				iframe.contents().find("#txt_password").val("******");
				iframe.contents().find("#txt_name").prop({readonly:true});
				iframe.contents().find("#btn_edit_password").on("click", function() {
					if ($(this).html() == "修改") {
						$(this).html("取消");
						iframe.contents().find("#txt_password").val("").prop({"readonly" : false});
						iframe.contents().find("#txt_passwordAgain").val("");
						// 火狐
						iframe.contents().find("#tr_passwordAgain").css({display : "table-row"});
					} else {
						$(this).html("修改");
						iframe.contents().find("#txt_password").val("").prop({"readonly" : true});
						iframe.contents().find("#txt_password").val("******");
						iframe.contents().find("#txt_passwordAgain").val("");
						iframe.contents().find("#tr_passwordAgain").css({display : "none"});
					}
				});
			};
		}

		window = jq.window({
			title : title,
			height : 350,
			width : 480,
			minimizable : false,
			modal : true,
			collapsible : false,
			maximizable : true,
			collapsible : true,
			draggable : true,
			resizable : true,
			contents : iframe,
			winId : 'user_edit',
			onComplete : function() {
				jq(this).mask({
					maskMsg : "页面加载中...",
					opacity : 1.0,
					timeout : 1000
				});
			},
			buttons : [ {
				iconCls : 'icon-save',
				text : '保存',
				handler : function() {
					formSubmit();
				}
			} ]
		});
	}
	function formSubmit() {
		var form = iframe.contents().find("#form");
		form.form('submit', {
			url : iframe.contents().find("#formAction").val(),
			onSubmit : function() {
				// 表单验证 ,要去掉中文的空格
				var name = $.trim(iframe.contents().find("#txt_name").val());
				if (name.length != 0) {
					iframe.contents().find("#txt_name").val(name);
				} else {
					jq.messager.alert("警告", "请输入用户名", 'warning');
					iframe.contents().find("#txt_name").val("");
					return false;
				}
				if (iframe.contents().find("#tr_passwordAgain").css('display') == "table-row"
						|| iframe.contents().find("#tr_passwordAgain")
								.css('display') == "block") {
					if (iframe.contents().find("#txt_passwordAgain").val().length < 6
							|| iframe.contents().find("#txt_password").val().length < 6) {
						jq.messager.alert("警告", '密码至少要6位', 'warning');
						iframe.contents().find("#txt_password").val("");
						iframe.contents().find("#txt_passwordAgain").val("");
						iframe.contents().find("#txt_password").focus();
						return false;
					} else {
						if (iframe.contents().find("#txt_passwordAgain").val() != iframe
								.contents().find("#txt_password").val()) {
							iframe.contents().find("#txt_password").val("");
							iframe.contents().find("#txt_passwordAgain").val("");
							jq.messager.alert("警告", '两次密码不一致', 'warning');
							iframe.contents().find("#txt_password").focus();
							return false;
						}
					}
				}
			},
			success : function(data) {
				var contined = easyuiFormSubmitValidate(data);
				if (contined < 0) {
					window.window("close");
					return;
				}
				var r = $.parseJSON(data);
				if (r.success) {
					jq.messager.alert('操作提示','密码修改成功，请重新登录！','warning',function() {	
						window.parent.location='#';
						top.location="login.jsp";
					});
				} else {
					jq.messager.alert("警告", r.msg, 'warning');
				}
			}
		});
	}
</script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" fit="true"
	scroll="no">
	<div region="north" split="false" noheader="true" border="false"
		style="overflow: hidden; height: 30px; background: url(resources/global/images/layout-browser-hd-bg.gif) #7f99be repeat-x center 50%; line-height: 20px; color: #fff; font-family: Verdana, 微软雅黑, 黑体">
		<span style="float: right; padding-right: 20px;" class="head">
			<font style="color: white">欢迎:</font>&nbsp; <label id="un">${sessionScope.loginUser.name}</label>
			&nbsp;&nbsp; <label style="color: white">|</label> &nbsp;&nbsp; <a
			href="javascript:void(0)" class="head" id="btn_modifyPasswd"
			style="color: white; text-decoration: none;"
			onclick="modifyPasswd('${sessionScope.loginUser.id}')">修改密码</a>
			&nbsp;&nbsp; <label style="color: white">|</label> &nbsp;&nbsp; <a
			href="#" id="logout" style="color: white; text-decoration: none;">安全退出</a>
		</span> <span style="padding-left: 10px; font-size: 16px;"><img
			src="resources/global/images/blocks.gif" width="20" height="20"
			align="absmiddle" />&nbsp;&nbsp;门户路由核心管理系统</span>
	</div>
	<div region="south" border="false" split="false" doSize="false"
		style="height: 40px; background: #F2F2F2; text-align: center">
		<div class="footer">Copyright:广东银结通电子支付结算有限公司</div>
	</div>
	<div style="width: 200px;" id="west"
		data-options="iconCls:'icon-house',title:'&nbsp;导航菜单',headerCls:'layout_header',region:'west',split:true,minWidth:'200',maxWidth:'200'"></div>
	<div id="mainPanle" region="center"
		style="background: #eee; overflow-y: hidden">
		<div id="tabs" class="easyui-tabs" fit="true" border="false">
			<div title="欢迎使用"
				style="padding: 20px; overflow: hidden; color: #7D9EC0; font-size: 50px">
			</div>
		</div>
	</div>
</body>
</html>
